<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<thead>
	<tr>
		<th onclick="sortList('name', 1, ${amount});" class="cursorPointer">Product</th>
		<th onclick="sortList('price', 1, ${amount});" class="cursorPointer">Prijs(Euro)</th>
		<th onclick="sortList('stock', 1, ${amount});" class="cursorPointer">Op voorraad</th>
		<th></th>
	</tr>
</thead>

<tbody>
	<c:forEach var="p" items="${products}" varStatus="rowCounter">
		<c:choose>
			<c:when test="${rowCounter.count % 2 == 1}">
				<c:set var="rowStyle" scope="page" value="odd"/>
				<c:set var="evenRow" scope="page" value="false"/>
			</c:when>
			<c:otherwise>
				<c:set var="rowStyle" scope="page" value="evenRow"/>
				<c:set var="evenRow" scope="page" value="true"/>
			</c:otherwise>
		</c:choose>
		<tr>
			<c:choose>
				<c:when test="${p.stock > 0}">
					<td id="product${p.id}" class="${rowStyle} cursorPointer" onclick="toggleOrderAmountField(${p.id}, ${evenRow});">${p.name}</td>		
					<td id="price${p.id}" class="${rowStyle} cursorPointer" onclick="toggleOrderAmountField(${p.id}, ${evenRow});">&euro; ${p.price}</td>
					<td class="available cursorPointer" onclick="toggleOrderAmountField(${p.id}, ${evenRow});">Ja</td>
				</c:when>
				<c:otherwise>
					<td class="${rowStyle}">${p.name}</td>		
					<td class="${rowStyle}">&euro; ${p.price}</td>
					<td class="unavailable">Nee</td>
				</c:otherwise>
			</c:choose>	
			
			<td id="amountField${p.id}"></td>
		</tr>
	</c:forEach>
	<tr>
		<td>Producten per pagina</td>
		<td>
			<select onchange="sortList(${order}, ${page}, null);" id="pppSelector">
				<option value="5"<c:if test="${amount == 5}"> selected="selected"</c:if>>5</option>
				<option value="10"<c:if test="${amount == 10}"> selected="selected"</c:if>>10</option>
				<option value="15"<c:if test="${amount == 15}"> selected="selected"</c:if>>15</option>
			</select>
		</td>
		<td>
			<c:if test="${page > 1}">
				<a onclick="sortList(${order}, ${page - 1}, ${amount});" class="pagination">&laquo;</a>&nbsp;
			</c:if>
			<c:forEach var="i" begin="1" end="${totalPages}" step="1">
					<a onclick="sortList(${order}, ${i}, ${amount});" class="pagination">${i}</a>&nbsp;
				</c:forEach>
			<c:if test="${totalPages > page}">
				<a onclick="sortList(${order}, ${page + 1}, ${amount});" class="pagination">&raquo;</a>
			</c:if>
		</td>
	</tr>
</tbody>